<template>
	<view class="">
		<u-navbar title="预约详情" :autoBack="true" :placeholder="true" />
		<u-gap height="5" bgColor="#f7f7f7"></u-gap>
		<view class="detail">
			<view class="del-itm">
				<text class="t1">预约门店</text>
				<text class="coreshop-font-14 line-red">{{data.storeName}}</text>
			</view>
			<view class="del-itm">
				<text class="t1">预约项目</text>
				<text class="coreshop-font-14 line-red">{{data.projectName}}</text>
			</view>
			<view class="del-itm">
				<text class="t1">预约状态</text>
				<!-- <text class="line-red coreshop-font-14">{{data.status == 0?'待到店':'已完成'}}</text> -->
				<text class="line-red coreshop-font-14">{{data.statusText}}</text>
			</view>
			<view class="del-itm">
				<text class="t1">预约员工</text>
				<text class="t2">{{data.staffName}}</text>
			</view>
			<view class="del-itm">
				<text class="t1">预约时间</text>
				<view class="t2">
					<view class="">{{data.appointmentTime}}</view>
					<view class="">{{data.estimatedEndTime}}</view>
				</view>
			</view>
			<view class="del-itm">
				<text class="t1">创建时间</text>
				<text class="t2">{{data.dateTime}}</text>
			</view>
		</view>
		<view class="btn" v-if="data.status === 0">
			<u-button text="取消预约" color="#e54d42" @click="onCel"></u-button>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				data:{}
			}
		},
		onLoad(opt) {
			this.data = opt
		},
		methods: {
			onCel(){
				let that = this
				this.$u.api.CancelAppointment({
					id: that.data.id
				}).then(res => {
					if(res.code === 0){
						that.$refs.uToast.show({
							message: '已取消',
							complete() {
								uni.navigateBack()
							}
						})
					}else {
						that.$refs.uToast.show({
							message: res.msg
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.detail{
		padding: 10px;
		background-color: #fff;
		font-size: 14px;
		line-height: 2;
		.del-itm{
			display:flex;
			justify-content: space-between;
			align-items: center;
			padding: 10px 0;
			border-bottom: 1px #f7f7f7 solid;
			.t2{
				font-size: 14px;
				color:#666;
			}
		}
	}
	.btn{
		margin-top: 10px;
		padding: 10px;
	}
</style>